﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using TFSTools.TFSLibrary;
using TFSTools.TFSLibrary.TestManagement;

namespace TFSTools.TestManagement.TestCaseReview
{
    /// <summary>
    /// Interaction logic for StepCommentWarning.xaml
    /// </summary>
    public partial class StepCommentWarning : Window
    {
        public StepCommentWarning()
        {
            InitializeComponent();
        }

        public void ShowWarning(TFSTestCase testCase)
        {
            var projectSettings = ProjectSettings.GetFromSettings();
            var connection = (TFSConnection)testCase.Connection;

            if (projectSettings[connection].ShowCommentWarning)
            {
                if (!testCase.IsCommentFieldExistsInTFS)
                {
                    this.ShowDialog();
                }

                if (chkDoNotShow.IsChecked == true)
                {
                    projectSettings.SaveToSettings(connection, null, false);
                }
            }
        }

        private void Hyperlink_RequestNavigate(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
        {
            try
            {
                System.Diagnostics.Process.Start(e.Uri.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occured.  " + ex.Message);
            }
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
